//
//  MKUICollectionViewCellModel.h
//  MKUI
//
//  Created by sushangjin on 14/12/29.
//  Copyright © 2020 sushangjin. All rights reserved.
//

#import "MKCollectionCellModel.h"
#import "MKUICollectionViewCellProtocol.h"

NS_ASSUME_NONNULL_BEGIN

@class MKUICollectionViewCellModel,MKUICollectionViewSectionModel,MKUICollectionViewModel;

typedef void(^MKUICollectionViewCellModelBlockC)(__kindof MKUICollectionViewCellModel *cellModel);
typedef void(^MKUICollectionViewCellModelBlockS)(__kindof MKUICollectionViewCellModel *cellModel,BOOL selected);
typedef BOOL(^MKUICollectionViewCellModelBlockM)(__kindof MKUICollectionViewCellModel *src,
										  __kindof MKUICollectionViewCellModel *dst);	//移動数据时觸發的动作

typedef BOOL(^MKUICollectionViewCellModelBlockD)(__kindof MKUICollectionViewCellModel *cellModel);	//刪除数据时觸發的动作


@interface MKUICollectionViewCellModel : MKCollectionCellModel
@property(nonatomic,assign) Class<MKUICollectionViewCellProtocol> cellClass;
@property(nonatomic,strong) NSString *reuseIdentity;//用於列表重用单元格视图时的标志符,默认为NSStringFromCGClass(self.class)

@property(nonatomic,assign) BOOL canDelete;//是否可以被删除,默认为NO
@property(nonatomic,assign) BOOL canMove;//是否可以被移動,默认为 NO
@property(nonatomic,copy,nullable) MKUICollectionViewCellModelBlockM whenMove;//移動位置觸發
@property(nonatomic,copy,nullable) MKUICollectionViewCellModelBlockD whenDelete;//删除触发

@property(nonatomic,weak,nullable) __kindof UICollectionViewCell<MKUICollectionViewCellProtocol> *collectionViewCell;//弱引用单元格视图
@property(nonatomic,readonly,nullable) UICollectionView *collectionView;
@property(nonatomic,copy,nullable) MKUICollectionViewCellModelBlockC whenClick;//点击时被触发
@property(nonatomic,copy,nullable) MKUICollectionViewCellModelBlockS whenSelected;//被触控事件选中时触发

@property(nonatomic) BOOL needReloadCell;//是否需要更新cell的视图内容

+ (instancetype)modelWithValue:(nullable id)modelValue cellClass:(Class)cellClass;
+ (instancetype)modelWithValue:(nullable id)modelValue cellClass:(Class)cellClass whenClick:(nullable MKUICollectionViewCellModelBlockC)whenClick;

- (void)didClickSelf;
- (void)didSelectedSelf:(BOOL)selected;
- (BOOL)didDeleteSelf;

 - (nullable __kindof MKUICollectionViewSectionModel *)sectionModel;
 - (nullable __kindof MKUICollectionViewModel *)collectionModel;
/**
 *  根据模型显示视图
 *	
 *  @param cell 视图对象
 */
- (void)displayCell:(UICollectionViewCell<MKUICollectionViewCellProtocol> *)cell;

/**
 *  刷新视图
 */
- (void)refresh;

//移除单元格
- (void)removeCellModelWithAnimated:(BOOL)animated completion:(void (^ __nullable)(BOOL finished))completion;
@end

NS_ASSUME_NONNULL_END
